<template>
  <h2 ref="dom">我是h2标签</h2>

  <ul>
    <li v-for="i in 5" :key="i" :ref="setDom">第{{i}}个li</li>
  </ul>
</template>

<script>
import { onMounted ,ref} from "vue";
export default {
  setup() {
    // Vue3.0 使用 ref 属性获取单个 Dom
    const dom = ref(null);
    onMounted(() => {
      console.log(dom.value);
      console.log(domlist);
    });
  // 获取v-for 遍历的Dom 或者组件 
    const domlist = []
    const setDom = (el)=>{
      domlist.push(el)
    }
    return {dom,setDom}

  },
};
</script>

<style>
</style>